﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.Mvc;

namespace Pr0ject0.App_Start
{
    public class RolesAndMembersConfig
    {
        public static void AddRoles()
        {
            string hiringManager = "Hiring Manager";
            string hiringSpecialist = "Hiring Specialist";
            string staffingExpert = "Staffing Expert";
            try
            {
                if (!Roles.RoleExists(hiringManager))
                {
                    Roles.CreateRole(hiringManager);
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (!Roles.RoleExists(hiringSpecialist))
                {
                    Roles.CreateRole(hiringSpecialist);
                }
            }
            catch (Exception e)
            {

            }


            try
            {
                if (!Roles.RoleExists(staffingExpert))
                {
                    Roles.CreateRole(staffingExpert);
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (!Roles.RoleExists("Kiosk"))
                {
                    Roles.CreateRole("Kiosk");
                }
            }
            catch (Exception e)
            {

            } 
        }

        public static void PopulateMembers()
        {
            try
            {
                if (Membership.FindUsersByName("robert.mccune").Count == 0)
                {
                    Membership.CreateUser("robert.mccune", "hello");
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("grant.kropf").Count == 0)
                {
                    Membership.CreateUser("grant.kropf", "gk");
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("rc").Count == 0)
                {
                    Membership.CreateUser("rc", "rc");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("john.bradley").Count == 0)
                {
                    Membership.CreateUser("john.bradley", "jb");
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("tracey.decorte").Count == 0)
                {
                    Membership.CreateUser("tracey.decorte", "td");
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("specialist").Count == 0)
                {
                    Membership.CreateUser("specialist", "specialist");
                    Roles.AddUserToRole("specialist", "Hiring Specialist");
                }

                
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("manager").Count == 0)
                {
                    Membership.CreateUser("manager", "manager");
                    Roles.AddUserToRole("Manager", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("staffing").Count == 0)
                {
                    Membership.CreateUser("staffing", "staffing");
                    Roles.AddUserToRole("staffing", "Staffing Expert");
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("manager1_3").Count == 0)
                {
                    Membership.CreateUser("manager1_3", "manager1_3");
                    Roles.AddUserToRole("manager1_3", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("manager2_1").Count == 0)
                {
                    Membership.CreateUser("manager2_1", "manager2_1");
                    Roles.AddUserToRole("manager2_1", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("manager2_2").Count == 0)
                {
                    Membership.CreateUser("manager2_2", "manager2_2");
                    Roles.AddUserToRole("manager2_2", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("manager2_3").Count == 0)
                {
                    Membership.CreateUser("manager2_3", "manager2_3");
                    Roles.AddUserToRole("manager2_3", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("manager3_1").Count == 0)
                {
                    Membership.CreateUser("manager3_1", "manager3_1");
                    Roles.AddUserToRole("manager3_1", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("manager3_2").Count == 0)
                {
                    Membership.CreateUser("manager3_2", "manager3_2");
                    Roles.AddUserToRole("manager3_2", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("manager3_3").Count == 0)
                {
                    Membership.CreateUser("manager3_3", "manager3_3");
                    Roles.AddUserToRole("manager3_3", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("manager4_1").Count == 0)
                {
                    Membership.CreateUser("manager4_1", "manager4_1");
                    Roles.AddUserToRole("manager4_1", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("manager4_2").Count == 0)
                {
                    Membership.CreateUser("manager4_2", "manager4_2");
                    Roles.AddUserToRole("manager4_2", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("manager4_3").Count == 0)
                {
                    Membership.CreateUser("manager4_3", "manager4_3");
                    Roles.AddUserToRole("manager4_3", "Hiring Manager");
                }
            }
            catch (Exception e)
            {

            }

            try
            {
                if (Membership.FindUsersByName("StoreRed").Count == 0)
                {
                    Membership.CreateUser("StoreRed", "StoreRed");
                    Roles.AddUserToRole("StoreRed", "Kiosk");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("StoreBlue").Count == 0)
                {
                    Membership.CreateUser("StoreBlue", "StoreBlue");
                    Roles.AddUserToRole("StoreBlue", "Kiosk");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("StoreGreen").Count == 0)
                {
                    Membership.CreateUser("StoreGreen", "StoreGreen");
                    Roles.AddUserToRole("StoreGreen", "Kiosk");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("StoreYellow").Count == 0)
                {
                    Membership.CreateUser("StoreYellow", "StoreYellow");
                    Roles.AddUserToRole("StoreYellow", "Kiosk");
                }
            }
            catch (Exception e)
            {

            }
            try
            {
                if (Membership.FindUsersByName("StorePurple").Count == 0)
                {
                    Membership.CreateUser("StorePurple", "StorePurple");
                    Roles.AddUserToRole("StorePurple", "Kiosk");
                }
            }
            catch (Exception e)
            {

            }
        }
    }
}